#ifndef WRAP_STDIOS_H
#define WRAP_STDIOS_H

#include <cstdio>

namespace Wrap
{

/// @see https://man7.org/linux/man-pages/man3/fclose.3.html
/// @param stream The fclose() function flushes the stream pointed to by
/// @c stream (writing any buffered output data using fflush(3)) and closes the
/// underlying file descriptor.
/// @return Upon successful completion, 0 is returned. Otherwise, EOF is
/// returned and errno is set to indicate the error. In either case, any
/// further access (including another call to fclose()) to the stream results
/// in undefined behavior.
/// @throw EBADF The file descriptor underlying stream is not valid.
/// @throw The fclose() function may also fail and set errno for any of the
/// errors specified for the routines close(2), write(2), or fflush(3).
int fclose_(FILE *stream);

/// @see https://man7.org/linux/man-pages/man3/fflush.3.html
/// @param stream For output streams, fflush() forces a write of all user-space
/// buffered data for the given output or update @c stream via the stream's
/// underlying write function.
/// @return Upon successful completion 0 is returned. Otherwise, EOF is
/// returned and errno is set to indicate the error.
/// @throw EBADF @c stream is not an open stream, or is not open for writing.
/// @throw The function fflush() may also fail and set errno for any of the
/// errors specified for write(2).
int fflush_(FILE *stream);

/// @see https://man7.org/linux/man-pages/man3/fopen.3.html
/// @param filename  The fopen() function opens the file whose name is the
/// string pointed to by @c filename and associates a stream with it.
/// @param modes The argument @c modes points to a string
/// @return Upon successful completion fopen(), return a FILE pointer.
/// Otherwise, NULL is returned and errno is set to indicate the error.
/// @throw EINVAL The @c modes provided to fopen() invalid.
/// @throw The fopen() functions may also fail and set errno for any of the
/// errors specified for the routine malloc(3).
/// @throw The fopen() function may also fail and set errno for any of the
/// errors specified for the routine open(2).
FILE *fopen_(const char * filename, const char *modes);

/// @see https://man7.org/linux/man-pages/man3/remove.3.html
/// @return On success, zero is returned. On error, -1 is returned, and errno
/// is set to indicate the error.
/// @throw The errors that occur are those for unlink(2) and rmdir(2).
int remove_(const char *filename);

} // namespace Wrap



#endif